var role1Manage = function() {
	var _init = function() {
		var table = $('#table_order');
		var tableUnit=table.dataTable({
			"processing": true,
			 "bPaginate": true, 
			// 开启服务器模式
			serverSide: true,
			"ajax": {
				url:url+"s"
			},
			"autoWidth": false,
			"columns": [
				{
					"width": "20%",//获取用户头像 
					"data": "orderNo"
				},{
					"width": "20%",//获取用户头像 
					"data": "payMethod",
					"render":function(data, type, row, meta) {
						if(data=='0'){
							return "微信支付";
						}
						if(data=='1'){
							return "支付宝支付";
						}
						if(data=='2'){
							return "网银支付";
						}
						return '--';
					}
				}
				,{
					"width": "20%",//获取消费金额
					"data": "total",
					"render":function(data, type, row, meta) {
						if(data){
							return data/100;
						}
						return '0.00';
					}
				},

				{
					"width": "20%",//获取购买条数
					"data": "serviceTotal",
					"render":function(data, type, row, meta) {
						if(data){
							return data;
						}
						return '0';
					}
				},
				{

					"data": "createDate",
					"render": function(data, type, row, meta) {
						return moment(data).format('YYYY-MM-DD HH:mm:ss');
					}
				}
				],
				"language": {
	                "lengthMenu": "每页显示 _MENU_ 条记录",
	                "emptyTable": "<div style='width:100%;text-align:center;'>暂无数据记录</div>",
	                "info": "显示 _START_ 至 _END_ 条数据，共 _TOTAL_ 条记录！",
	                "zeroRecords": "没有搜索到匹配记录",
	                "infoEmpty": "",
	                "infoFiltered": "",
	                "processing": "数据加载中,请稍后..."
	            },
	            "pageLength": 5,
	            "order": [
	               
	            ],
	            "columnDefs": [{
	                "orderable": false,
	                "targets": [0,1,2,3,4]
	            }],
	            "dom": "<'row'<'.col-md-6 col-sm-12'><'col-md-6 col-sm-12'>r>" +
	            "<t>" +
	            "<'table_b relative'<'col-md-5'i><'col-md-7'>p>",
	            "fnInitComplete": function() {}
					/*"fnInitComplete": function() {}*/
		});
	// 关闭弹框
		$(".modal").on('hidden.bs.modal', function(e) {
			$('.modal .help-block').html(''); // 清空提示
//			$('.modal input').val(''); // 清空 input
		});
		// 选择短信套餐
		$(".package input[name='serviceTotal']:checked").parent("label").addClass("active");

		$(".package label").click(function(){
			$(this).addClass("active").siblings("label").removeClass("active");
			$(this).find("input[name='serviceTotal']").prop("checked",true);
			$(this).siblings("label").find("input[name='serviceTotal']").prop("checked",false);

		});
		$("#buybtn").click(function(){
			var _data = $("#smsForm").serializeObject();
			var _serviceTotal=_data.serviceTotal;
			$.ajax({
				url : '/a/sms/recharge',
				type : 'post',
				dataType : 'json',
				contentType:"application/json; charset=utf-8",
				data : JSON.stringify({serviceTotal:_serviceTotal}),
				async: false
			}).done(function(r){
				if (r.status === '1') { 
					$("#wximg").attr("src",r.data);
				} else if (r.status == '2') {	
				}
			});
		});	
	}


    return {
        init: function() {
            _init();
        }

    };

}();



$(function() {
	role1Manage.init();
});